<?php
/**
 * IndexController.php
 * 入口文件
 * 
 * @author  王中艺 <wangzy_smile@qq.com>
 * @date    2019-03-15 15:09:17
 */

namespace App\Http\Controllers\App;
use Illuminate\Routing\Controller;
use Illuminate\Http\Request;
use App\Utils\Http;

class IndexController extends Controller {

    function index(Request $request){
        // return 'Hello zhongyi!';

        // $res = Http::post('http://yi.dev/api.php', ['name' => 'wangzhongyi'], [
        //     'Content-type' => 'application/json'
        // ]);

        $https = [
            'api1' => [
                'method' => Http::METHOD_GET,
                'url' => 'http://yi.dev/api.php?name=api1'
            ],
            'api2' => [
                'method' => Http::METHOD_POST,
                'url' => 'http://yi.dev/api.php?name=api2',
                'body' => [
                    'name' => 'wangzhongyi'
                ]
            ],
            'api3' => [
                'method' => Http::METHOD_POST,
                'url' => 'http://yi.dev/api.php?name=api3',
                'header' => [
                    'Content-type' => 'application/json',
                    'Authorized' => 'wangzhongyi',
                ],
                'body' => [
                    'name' => 'wangzhongyi'
                ]
            ],
        ];

        $res = Http::multi($https);
        return json_encode($res);
    }
}
